package com.doit.day01;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.ACL;

import java.io.IOException;
import java.util.List;

/**
 * 1.获取到zk的对象
 * 2.调用api
 */
public class ListDemo {
    public static void main(String[] args) throws Exception {

        //创建zk的对象
        ZooKeeper zk = new ZooKeeper("linux01:2181",2000,null);

        //对象调用api,遍历根节点下面的所有子节点
        List<String> children = zk.getChildren("/", null);
        for (String child : children) {
            System.out.println("根节点下有哪些子节点："+child);
        }

        //关闭资源
        zk.close();

    }
}
